package com.mju.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.mju.exception.ServiceException;
import com.mju.service.UsersService;
import com.mju.utils.RespData;

@RestController
@RequestMapping("/users")
public class UsersController {
	@Autowired
	private UsersService usersService;
	
	@GetMapping("/resetAll")
	public RespData resetAll() {
		int row=usersService.resetAllPasswd();
		String msg="成功重置"+row+"条记录";
		return RespData.success(msg);
	}
	
	@GetMapping("/reset")
	public RespData reset(String studentno) throws ServiceException {
		int row=usersService.resetPasswd(studentno);
		if(row>0) return RespData.success("密码重置成功");
		throw new ServiceException("密码重置失败");
	}
}
